<template>
	<view class="mord">
		<view class="input">
			<view class="li">

				<input type="password" v-model="old" placeholder="请输入旧密码" />

			</view>
			<view class="li">

				<input type="password" v-model="newpass" placeholder="请输入新密码" />

			</view>
			<view class="li">

				<input type="password" v-model="val" placeholder="请再次输入新密码" />

			</view>
		</view>
		<view class="next" @click="next">
			修改密码
		</view>

	</view>
</template>

<script>
	export default {
		name: "",
		components: {

		},
		data() {
			return {
				val: '',
				tim: 0,
				newpass: '',
				old: '',
				user: null,
			}
		},
		onLoad() {
			var that = this;
			var token = that.$SysCache.get('token');
			that.$Request.post(
				that.$api.httpApi.user.userinfo + '&token=' + that.$SysCache.get('token'), {
					"token": token
				}
			).then(res => {
				if (res.code == 200) {
					that.user = res.data;
				}
			});
		},
		methods: {

			next() {
				var that = this;
				if (that.val == that.newpass) {
					let datas = {
						uid: that.user.id,
						old_password: that.old,
						password: that.val
					}

					this.$Request.post4(
						this.$api.httpApi.user.userEditPwd, datas
					).then(res => {
						if (res.code == 1) {
							uni.showToast({
								title: '修改成功！',
								duration: 1500,
								success: function() {
									setTimeout(function() {
										uni.navigateBack({
											delta: 1
										})
									}, 2000)
								}
							})
							
						}

					})

					

				} else {
					uni.showToast({
						title: '两次输入的密码不一致！'
					})
				}

			},

		}


	}
</script>

<style scoped>
	uni-page-body {
		height: 100%;
	}

	.mord {
		height: 100%;
		background: #EEEEEE;
		padding-top: 230rpx;
	}

	.next {
		display: block;
		width: 75%;
		margin: auto;
		height: 65rpx;
		background: rgba(4, 0, 0, 1);
		border-radius: 33px;
		font-size: 30rpx;
		font-family: Microsoft YaHei;
		font-weight: 400;
		color: rgba(255, 255, 255, 1);
		text-align: center;
		line-height: 65rpx;
		margin-top: 77rpx;
	}

	.h2 {
		width: 65%;
		margin: auto;
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #666666;
		text-align: left;
		margin-top: 44rpx
	}

	.h2 navigator {
		color: rgba(240, 64, 111, 1);
		display: initial;
	}

	.h1 {
		font-size: 26rpx;
		font-family: Microsoft YaHei;
		font-weight: 300;
		color: rgba(68, 68, 68, 1);
		text-align: center;
		padding-top: 100rpx;
	}

	.input {
		width: 75%;
		margin: auto;
		/* margin-top: 100rpx; */
	}

	.input .p {
		font-size: 28rpx;
		font-family: Microsoft YaHei;
		font-weight: 300;
		color: rgba(102, 102, 102, 1);
		margin-top: 149rpx;
	}

	.input .li {
		border-bottom: 1px solid #CECECE;
		padding-bottom: 12rpx;
		margin-bottom: 45rpx;
		margin-top: 23rpx;
	}

	.input .li image {
		width: 28rpx;
		display: inline-block;
		vertical-align: middle;
	}

	.input .li input {
		display: inline-block;
		width: 100%;
		vertical-align: middle;
		/* margin-left: 21rpx; */
		font-size: 30rpx;
		color: #B7B7B7;
		font-weight: normal;
	}

	.input .li .min {
		width: calc(100% - 130rpx - 65rpx);
		font-size: 24rpx;
		font-family: Microsoft YaHei;
		font-weight: 300;
		color: rgba(180, 180, 180, 1);
	}

	.input .li .right {
		width: 176rpx;
		height: 54rpx;
		background: rgba(240, 64, 111, 1);
		border-radius: 27rpx;
		margin-left: 16rpx;
		display: inline-block;
		vertical-align: middle;
		font-size: 22rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #fff;
		text-align: center;
		line-height: 54rpx;
	}

	.input .li .rs {
		background: #CECECE;
		color: #fff;
	}

	.input .li .right .b {
		display: inline-block;
		width: 40rpx;
		text-align: center;

	}

	.input .li .right .b image {
		display: inline-block;
		width: 100%;
		vertical-align: middle;
	}

	.input .li .x {
		display: inline-block;
		vertical-align: middle;
		width: 1px;
		height: 30rpx;
		background: #E5E5E5;
		margin-left: 25rpx;
	}

	.input .li .right .but {
		font-size: 26rpx;
		width: calc(100% - 65rpx - 16rpx - 15rpx);
		margin-left: 25rpx;
		display: inline-block;
		vertical-align: middle;
		color: #8F8F94;
	}

	/* 	.input .p {
		font-size: 26rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: rgba(162, 162, 162, 1);
		margin-top: 44rpx;
		text-align: left;
	} */
</style>
